import React from "react";



export default class PackTradeApply extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            ison:false
        }
    }

    over() {
        this.setState({
            ison:true
        });
    }

    out() {
        this.setState({
            ison:false
        });
    }
    downloadfile(name,url){
        window.location.href=url+'?attname='+name
    }

    delqiniufile(){
        let item = this.props.item
        this.props.delqiniufile(item,item.fileKey);
    }

    render() {
        let name;
        let url;
        if(this.props.item){
            name = this.props.item.name;
            url = this.props.item.url;
        }else{
            name = ''
            url=''
        }
        return (
            <div className="order_input_showdelet" onMouseOver={this.over.bind(this)} onMouseOut={this.out.bind(this)}>
                <a className={this.props.type=='accessory'?"":"order_a_filename"}>{name}</a>
                <span className={this.state.ison?"order_span_filedowndelte order_span_filedown_icon":"order_span_filedowndelteunchose"}  onClick={this.downloadfile.bind(this,name,url)}>下载</span>
                <span className={this.state.ison?"order_span_filedowndelte order_span_filedelete_icon":"order_span_filedowndelteunchose" } onClick={this.delqiniufile.bind(this)}>删除附件</span>
            </div>
        );
    }
}
